/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.ec.taobao.remote.RemoteTaobaoOrderServiceImpl
   Module Description   :

   Date Created      : 2010/12/13
   Original Author   : jeffma
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.ec.taobao.remote;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.yaodian100.core.common.utils.ServerValue;
import com.yaodian100.ec.order.entity.Orders;
import com.yaodian100.ec.taobao.service.TaobaoService;

/**
 * @author jeffma
 * 
 */
public class RemoteTaobaoOrderServiceImpl implements RemoteTaobaoOrderService {

	@Autowired
	private TaobaoService taobaoService;

	private boolean debug = true;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yaodian100.ec.taobao.remote.RemoteTaobaoOrderService#getIncrement(java.util.Date, java.util.Date,
	 * java.lang.String)
	 */
	@Override
	public long getIncrement(Date start, Date end, String status) {
		long result = 0;
		if (!isDebug()) {
			// 非 debug 才執行
			result = taobaoService.tradesSoldIncrementGet(start, end, status);
		} else {
			// by pass
		}
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yaodian100.ec.taobao.remote.RemoteTaobaoOrderService#getTrade(java.lang.String)
	 */
	@Override
	public Orders getTrade(String tid) {
		Orders result = taobaoService.getTrade(tid);
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yaodian100.ec.taobao.remote.RemoteTaobaoOrderService#getTrades(java.util.Date, java.util.Date,
	 * java.lang.String, int)
	 */
	@Override
	public List<Orders> getTrades(Date start, Date end, String status, int page) {
		List<Orders> result = taobaoService.getTrades(start, end, status, page);
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yaodian100.ec.taobao.remote.RemoteTaobaoProductService#setDebug(boolean)
	 */
	@Override
	public boolean setDebug(boolean debugFlag) {
		debug = debugFlag;
		return debug;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.yaodian100.ec.taobao.remote.RemoteTaobaoProductService#isDebug()
	 */
	@Override
	public boolean isDebug() {
		if ("www.yaodian100.com".equals(ServerValue.getFrontHostname())) {
			return false;
		} else {
			// sit, dev 如果 debug 沒有改為 false (預設 true), 不執行
			return debug;
		}
	}

}
